<script type="text/javascript">
    $(function(){
        $('body').data('check',false);

        $('form#changePass input[type=password]').blur(function(){

            var id = $(this).attr('id');
            var dataCont = {};

            $('form#changePass input[type=password]').each(function(i,elm){
                dataCont[$(elm).attr('id')] = $(elm).val();
            });

            $.ajax({
                url:'/users/user-login/checking/format/json',
                dataType:'JSON',
                data:dataCont,
                type:'POST',
                success:function(resp){
                    validation(id,resp);
                }
            });
        });
    });

function validation(id,resp){
        var errors = resp[id],i,ok,m,msg=[],ul,li=[],max,ok,er,imgOk;
        ok = $('#'+id+'.ok');
        er = $('#errors-'+id+'.errors');

        if(resp[id] !== null){

            $('body').data('check',false);
            if(ok.length > 0 || er.length > 0){er.remove();ok.remove();}

            for( m in errors){
                msg.push(errors[m]);
            }
            ul = $('<ul>',{id:'errors-'+id,'class':'errors'});
            max = msg.length;
            for( i=0;i < max;i+=1){

                li.push($('<li>').append(msg[i]));
            }
            ul.append(li);

            if(li.length > 1){
                $('#'+id).css({'border-color':'#FF0000','margin-bottom':'0px'}).after(ul);
            }else if(li.length == 1){
                $('#'+id).css({'border-color':'#FF0000','margin-bottom':'0px'}).after(ul.css('margin-bottom','13px'));
            }

        }else{
            $('body').data('check',true);
            if(ok.length > 0 || er.length > 0){er.remove();ok.remove();}
            imgOk = $('<img>',{id:id,'class':'ok',src:'images/ok.png',style:'padding-left:5px;'});
            $('#'+id).css({'border-color':'#AAAAAA','margin-bottom':'26px'}).after(imgOk);
        }

}
function check(){
    var dataCont = {};

    $('form#changePass input[type=password]').each(function(i,elm){
        dataCont[$(elm).attr('id')] = $(elm).val();
    });

    $.ajax({
        url:'/users/user-login/checking/format/json',
        dataType:'JSON',
        data:dataCont,
        type:'POST',
        success:function(resp){
            for(var id in resp){
                    validation(id,resp);
            }
        }
    });


    return   $('body').data('check');
}
</script>

<?=$this->headTitle('Восстановление пароля')?>
<p>Восстановление пароля</p>
<?=$this->form?>